<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/6/19 0019
 * Time: 16:43
 */

namespace app\api\controller\v1;


use library\Controller;

class IntegralRule extends Controller
{
    /**
     * 获取积分充值配置
     * @throws \think\Exception
     * @throws \think\exception\PDOException
     */
    public function index()
    {
        $integral_recharge_discount = sysconf('integral_recharge_discount') ?: 1;
        $integral_recharge_rule = trim(sysconf('integral_recharge_rule'));
        $integral_recharge_rule = array_filter(explode("|",$integral_recharge_rule));
        $rule = [];
        foreach ($integral_recharge_rule as $item) {
            $rule[] = [
                'integral' => $item,
                'price' => $item*$integral_recharge_discount
            ];
        }
        $result = [
            'integral_recharge_discount' => $integral_recharge_discount,
            'integral_recharge_rule' => $rule,
        ];
        $this->success('success',$result);
    }
}